package com.asset.dispoal.file.evidenceRecognition.service;

import com.asset.dispoal.file.evidenceRecognition.api.EvidenceRecognitionService;
import com.asset.dispoal.file.evidenceRecognition.domain.db.entity.EvidenceFileDto;
import com.asset.dispoal.file.evidenceRecognition.domain.dto.EvidenceFileProDto;
import com.asset.dispoal.file.evidenceRecognition.dto.CaseEvidenceRecognitionRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.DownloadAndDelEvidenceRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.EvidenceRecognitionProRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.EvidenceRecognitionRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.FileByZipRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.MergeEvidenceDownloadRequest;
import com.asset.dispoal.file.evidenceRecognition.dto.SingleEvidenceRecognitionRequest;
import com.asset.dispoal.file.evidenceRecognition.service.commom.CaseEvidenceUploadCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.DownloadAndDelEvidenceCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.DownloadFileByZipCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.DownloadMergeEvidenceCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.EvidenceUploadCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.EvidenceUploadProCommand;
import com.asset.dispoal.file.evidenceRecognition.service.commom.SingleEvidenceUploadCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @author qr
 * @date 2022/4/14$
 */
@Service
public class EvidenceRecognitionServiceImpl implements EvidenceRecognitionService {

    @Autowired
    EvidenceUploadCommand command;

    @Autowired
    private SingleEvidenceUploadCommand singleEvidenceUploadCommand;

    @Autowired
    private DownloadFileByZipCommand downloadFileByZipCommand;

    @Autowired
    private DownloadAndDelEvidenceCommand downloadAndDelEvidenceCommand;

    @Autowired
    private DownloadMergeEvidenceCommand downloadMergeEvidenceCommand;

    @Autowired
    CaseEvidenceUploadCommand caseEvidenceUploadCommand;

    @Autowired
    EvidenceUploadProCommand evidenceUploadProCommand;

    @Override
    public Result evidenceUpload(String chunks, String chunk, String task_id, String name, EvidenceRecognitionRequest evidenceRecognitionRequest, MultipartFile file, String state, String filename, String uuid) {
        EvidenceFileDto fileDto = new EvidenceFileDto();
        fileDto.setFile(file);
        fileDto.setChunk(chunk);
        fileDto.setChunks(chunks);

        fileDto.setEvidenceRecognitionRequest(evidenceRecognitionRequest);
        fileDto.setTaskId(task_id);
        fileDto.setState(state);
        fileDto.setName(filename);
        fileDto.setUuid(uuid);
        return command.execute(fileDto);
    }

    @Override
    public Result evidenceUploadPro(String chunks, String chunk, String taskId, String name, EvidenceRecognitionProRequest evidenceRecognitionRequest, MultipartFile file, String no, String state, String filename, String uuid) {
        EvidenceFileProDto fileDto = new EvidenceFileProDto();
        fileDto.setFile(file);
        fileDto.setChunk(chunk);
        fileDto.setChunks(chunks);

        fileDto.setEvidenceRecognitionRequest(evidenceRecognitionRequest);
        fileDto.setName(name);
        fileDto.setTaskId(taskId);
        fileDto.setNo(no);
        fileDto.setState(state);
        fileDto.setName(filename);
        fileDto.setUuid(uuid);
        return evidenceUploadProCommand.execute(fileDto);
    }

    @Override
    public Result singleEvidenceUpload(SingleEvidenceRecognitionRequest request) {
        return singleEvidenceUploadCommand.execute(request);
    }

    @Override
    public Result<String> downloadFileByZip(FileByZipRequest request) {
        return downloadFileByZipCommand.execute(request);
    }

    @Override
    public Result<String> downloadAndDelEvidence(DownloadAndDelEvidenceRequest request) {
        return downloadAndDelEvidenceCommand.execute(request);
    }

    @Override
    public Result downloadMergeEvidence(MergeEvidenceDownloadRequest request) {
        return downloadMergeEvidenceCommand.execute(request);
    }

    @Override
    public Result caseEvidenceUpload(CaseEvidenceRecognitionRequest request) {
        return caseEvidenceUploadCommand.execute(request);
    }
}